

export class AppStorage {
  static APP_ID_KEY = "__APP_ID__";
  static USER_INFO_KEY = "__USER_INFO__";

  static setAppId(appId: string) {
    window.localStorage.setItem(this.APP_ID_KEY, appId);
  }

  static getAppId() {
    return window.localStorage.getItem(this.APP_ID_KEY) || "";
  }

  static setUserInfo(userInfo: any) {
    window.localStorage.setItem(this.USER_INFO_KEY, JSON.stringify(userInfo));
  }

  static getUserInfo() {
    let userInfoStr = window.localStorage.getItem(this.USER_INFO_KEY) || "";
    let userInfo = {};
    try {
      userInfo = JSON.parse(userInfoStr);
    } catch (e) {
      console.error("UserInfo 缓存转换失败");
    }
    return userInfo;
  }
}
